package com.msk.sys.service;


import com.msk.sys.domain.Menu;
import com.msk.sys.mapper.MenuDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class MenuService  extends CrudService<MenuDao, Menu> {


	public List<Menu> findListByParentId(Menu menu){
		List<Menu> list = dao.findListByParentId(menu);
		for (Menu menu1 : list) {
			if(menu1.getChildCount() > 0){
				menu1.setUserId(menu.getUserId());
				menu1.setChildList(this.findListByParentId(menu1));
			}
		}
		return list;
	}

	public Menu findByMenu(Menu menu){
		return dao.findByMenu(menu);
	}

}
